package com.saint.farmshop.Controller;

import com.saint.farmshop.Entity.Address;
import com.saint.farmshop.Entity.User;
import com.saint.farmshop.Service.ServiceImpl.UserServiceImpl;
import com.saint.farmshop.Utils.Result;
import com.saint.farmshop.Utils.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户控制器
 *
 * @author Saint
 * @date 2022/05/21
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserServiceImpl userService;
    @RequestMapping("/login")
    public User userLogin(@RequestBody User user){
        return userService.userLogin(user);
    }

    @RequestMapping("/update")
    public Result updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }

    @RequestMapping("/getUserList")
    List<User> getUserList(){
        return userService.getList();
    }

    @RequestMapping("/addAddress")
    Result addAddress(@RequestBody Address address, @RequestParam String openId){
        return userService.addAddress(address,openId);
    }
}
